package platform.nettyclient.demo;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import platform.nettyclient.handle.Docer;
import platform.nettyclient.handle.MyClientHandler;
import platform.nettyclient.handle.MyDecoder;
import platform.nettyclient.handle.MyEncoder;

public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        // 自定义解码
        socketChannel.pipeline().addLast(new MyDecoder());
        // 自定义编码
        socketChannel.pipeline().addLast(new MyEncoder());

        // 消息出站处理器，在client发送消息时会触发此处理器
        socketChannel.pipeline().addLast(new MyOutMsgHandler());
        // 消息入站处理器
        socketChannel.pipeline().addLast(new MyInMsgHandler());
    }
}
